<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@include file="/common/definition.jsp"%>
<%@ page language="java" import="java.util.*"%>
<html:html>
<tiles:insert beanName="shop-definition" flush="true">
	<tiles:put name="title"> Welcome </tiles:put>
	<tiles:put name="body" type="string">
	<div class="col-md-10" style="padding-left: 15px;">
		<div class="col-md-12 mainHome" >
			<div class="col-md-12 text-center">
				<h1>Đăng bán sản phẩm</h1>
			</div>
			<s:form name="saleProduct" action="saleProduct" cssClass="form-horizontal" role="form"
				theme="simple" enctype="multipart/form-data">
				<s:property value="shopModel.messageAddShopProduct"/>
				<div class="form-group">
					<label class="col-sm-3 control-label" style="padding-top: 0">Sản
						phẩm:</label>
					<div class="col-sm-9">
						<strong><s:property value="productInfo.productName" />
							<s:property value="productInfo.catName" /> <s:property
								value="productInfo.brandName" /> </strong>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label" style="padding-top: 0">Giá
						:</label>
					<div class="col-sm-5">
						<div class="input-group">
							<input type="text" class="form-control"
								name="agentProduct.sellingPrice"> <span
								class="input-group-addon">.000 VND</span>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label" style="padding-top: 0">Tình
						Trạng Hàng Hóa:</label>
					<div class="col-sm-5 ">
						<select name="agentProduct.condition" class="form-control ">
							<option value="BrandNew">Mới</option>
							<option value="SecondHand">2nd</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label" style="padding-top: 0">Thời
						gian bảo hành:</label>
					<div class="col-sm-5 ">
						<div class="input-group">
							<input type="text" class="form-control"
								name="agentProduct.warranty"> <span
								class="input-group-addon">&nbsp;&nbsp;Tháng&nbsp;&nbsp;</span>
						</div>
					</div>
				</div>
				<s:if test="saleType ==1">
					<div class="form-group">
						<label class="col-sm-3 control-label">Hình ảnh</label>
						<div class="col-sm-9 ">
							<s:file name="imgUpload" multiple="multiple" />
						</div>
					</div>
					<div class="form-group" style="padding-top: 80px; padding-left: 5px; padding-right: 5px">
					<s:textarea id="editor1" name="agentProduct.contentOfShop" rows="10" cols="80" value="%{productInfo.contentOfWeb}" />
		            <script>
		                // Replace the <textarea id="editor1"> with a CKEditor
		                // instance, using default configuration.
		                CKEDITOR.replace( 'editor1' );
		            </script>
            </div>
				</s:if>
				<s:hidden name="productID" value="%{productInfo.productID}" />
				<s:hidden name="saleType" value="%{saleType}" />
				<div class="form-group">
					<div class="col-sm-offset-3 col-sm-10">
						<button type="submit" class="btn btn-primary btn-sm">Đăng
							bán</button>
						<button type="reset" class="btn btn-default">Nhập lại</button>
					</div>
				</div>
			</s:form>
			<script type="text/javascript">
			var validator = new FormValidator('makeDiscount', 
			[{
				name: 'agentProduct.sellingPrice',  
				display: 'giá',
				rules: 'required|max_length[12]'
			},{
				name: 'agentProduct.warranty',  
				display: 'thời gian bảo hành',
				rules: 'required|max_length[3]'
			}], function(errors, evt) {
						var SELECTOR_ERRORS = $('.error_box'),
						SELECTOR_SUCCESS = $('.success_box');
						
					if (errors.length > 0) {
						SELECTOR_ERRORS.empty();
						for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
							SELECTOR_ERRORS.append(errors[i].message + '<br />');
						}
						
						SELECTOR_SUCCESS.css({ display: 'none' });
						SELECTOR_ERRORS.fadeIn(200);
					} else {
						SELECTOR_ERRORS.css({ display: 'none' });
						SELECTOR_SUCCESS.fadeIn(200);
					}			
				});
			</script>
		</div>
	</div>
	</tiles:put>
</tiles:insert>
</html:html>
